package com.app.micaihu.view.newsdetail.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.app.micaihu.R;
import com.app.micaihu.base.AppBaseAdapter;
import com.app.micaihu.bean.comment.PariseBean;
import com.app.micaihu.custom.view.CustomImageView;
import com.app.utils.util.image.LoadImageUtils;

import java.util.List;

/**
 * 点赞适配器
 * Created by linkai on 2016/12/5.
 */
public class PariseAdapter extends AppBaseAdapter<PariseBean> {


    public PariseAdapter(List<PariseBean> list, Context context) {
        super(list, context);
    }

    @Override
    public View creatView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if(convertView == null){
            convertView = inflater.inflate(R.layout.item_parise_list,null);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else{
            viewHolder = (ViewHolder) convertView.getTag();
        }
        PariseBean pariseBean = list.get(position);
        if(pariseBean != null){
            LoadImageUtils.getInstance().loadCircleImage(viewHolder.civHead, pariseBean.getHeadPic());
            viewHolder.tvNickName.setText(pariseBean.getNickName());
        }
        return convertView;
    }

    class ViewHolder {
        CustomImageView civHead;
        TextView tvNickName;

        ViewHolder(View convertView) {
            civHead = (CustomImageView) convertView.findViewById(R.id.civ_head);
            tvNickName = (TextView) convertView.findViewById(R.id.tv_nickname);
        }
    }
}
